From 5de53804a13731f7928b95ae2bf96976e3078a40 Mon Sep 17 00:00:00 2001 From: Michael Fulbright Date: Tue, 9 Nov 1999 17:24:15 +0000 Subject: [PATCH] Figured out problem with loading Progressive JPEG's progressively (say 1999-11-09 Michael Fulbright * src/io-jpeg.c (image_load_increment): Figured out problem with loading Progressive JPEG's progressively (say that 10 times fast). Currently for Progressive JPEG's the entire image is loaded before it is displayed. libjpeg supports a fancier mechanism which I may implement later. With these changes all JPEG formats appear to load properly for me. --- gdk-pixbuf/ChangeLog | 8 ++++++++ gdk-pixbuf/io-jpeg.c | 20 +++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index da24c73ba0..992178ea94 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -2,6 +2,14 @@ * src/io-pnm.c : Finished progressive PNM loading code. Should handle all types of PNM files now. + + * src/io-jpeg.c (image_load_increment): Figured out problem with + loading Progressive JPEG's progressively (say that 10 times fast). + Currently for Progressive JPEG's the entire image is loaded before + it is displayed. libjpeg supports a fancier mechanism which I may + implement later. + + With these changes all JPEG formats appear to load properly for me. 1999-11-08 Jonathan Blandford diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c index 119e9e5173..208ec01923 100644 --- a/gdk-pixbuf/io-jpeg.c +++ b/gdk-pixbuf/io-jpeg.c @@ -354,6 +354,7 @@ image_load_increment (gpointer data, guchar *buf, guint size) guint num_left, num_copy; guint last_bytes_left; guint spinguard; + gboolean first; guchar *bufhd; g_return_val_if_fail (context != NULL, FALSE); @@ -384,10 +385,13 @@ image_load_increment (gpointer data, guchar *buf, guint size) bufhd = buf; } + if (num_left == 0) + return TRUE; last_bytes_left = 0; spinguard = 0; - while (src->pub.bytes_in_buffer != 0 || num_left != 0) { + first = TRUE; + while (TRUE) { /* handle any data from caller we haven't processed yet */ if (num_left > 0) { @@ -410,9 +414,10 @@ image_load_increment (gpointer data, guchar *buf, guint size) num_left -= num_copy; } else { /* did anything change from last pass, if not return */ - if (last_bytes_left == 0) + if (first) { last_bytes_left = src->pub.bytes_in_buffer; - else if (src->pub.bytes_in_buffer == last_bytes_left) + first = FALSE; + } else if (src->pub.bytes_in_buffer == last_bytes_left) spinguard++; else last_bytes_left = src->pub.bytes_in_buffer; @@ -434,12 +439,13 @@ image_load_increment (gpointer data, guchar *buf, guint size) context->got_header = TRUE; +#if 0 if (jpeg_has_multiple_scans (cinfo)) { g_print ("io-jpeg.c: Does not currently " "support progressive jpeg files.\n"); return FALSE; } - +#endif context->pixbuf = gdk_pixbuf_new(ART_PIX_RGB, /*have_alpha*/ FALSE, 8, @@ -471,6 +477,7 @@ image_load_increment (gpointer data, guchar *buf, guint size) context->did_prescan = TRUE; } else { + /* we're decompressing so feed jpeg lib scanlines */ guchar *lines[4]; guchar **lptr; @@ -488,11 +495,6 @@ image_load_increment (gpointer data, guchar *buf, guint size) rowptr += context->pixbuf->art_pixbuf->rowstride;; } -#ifdef IO_JPEG_DEBUG_GREY - for (p=lines[0],i=0; i< context->pixbuf->art_pixbuf->rowstride;i++, p++) - *p = 0; - -#endif nlines = jpeg_read_scanlines (cinfo, lines, cinfo->rec_outbuf_height); if (nlines == 0) -- 2.30.2